package com.ruoyi.common.core.domain;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @Classname Tree
 * @Author: sunluquan
 * @Date: 2022/4/16 13:10
 * @Description TODO
 */
@Data
public class Tree<T> implements Serializable {

    private static final long serialVersionUID = 1L;



    public Tree(T source) {
        this.source = source;
    }

    public Tree(Serializable id, String name, T source) {
        this.id = id;
        this.name = name;
        this.source = source;
    }

    //编号
    private Serializable id;
    //名称
    private String name;
    //对象数据源
    private T source;
    //当前对象父类
    private T parent;
    //当前对象子类
    private List<Tree<T>> child;

    public void appendChild(Tree<T> t) {
        if(child==null)
            child = new ArrayList<>();
        child.add(t);
    }
}
